//
//  UIButton+Extension.swift
//  weibo
//
//  Created by 张宏芝 on 15/9/6.
//  Copyright © 2015年 kama. All rights reserved.
//

import UIKit

extension UIButton{
    
    convenience init(title:String,imageName:String,color:UIColor,fontSize:CGFloat){
        self.init()
        
        setTitle(title, forState: UIControlState.Normal)
        setTitleColor(color, forState: UIControlState.Normal)
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
    }
    
    convenience init(title: String, fontSize: CGFloat, color: UIColor = UIColor.whiteColor(), backColor: UIColor = UIColor.darkGrayColor()) {
        self.init()
        
        setTitle(title, forState: UIControlState.Normal)
        setTitleColor(color, forState: UIControlState.Normal)
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
        backgroundColor = backColor
        
    }
    
    convenience init (imageName:String) {
        self.init()
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        sizeToFit()
    }
}
